//
//  CXDestinationCollectionViewCell.m
//  Travel
//
//  Created by dllo on 15/11/29.
//  Copyright © 2015年 doll. All rights reserved.
//

#import "CXDestinationCollectionViewCell.h"
#import "CXDestinationModel.h"
#import "UIImageView+WebCache.h"
#import "UIImage+GIF.h"

@interface CXDestinationCollectionViewCell ()

@property (nonatomic, retain)UIImageView *coverImg;
@property (nonatomic, retain)UILabel *titleLable;

@end

@implementation CXDestinationCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.coverImg = [[UIImageView alloc]init];
        //self.coverImg.layer.masksToBounds = YES;
        self.coverImg.layer.cornerRadius = 10;
        self.coverImg.clipsToBounds = YES;
        [self.contentView addSubview:self.coverImg];
        
        self.titleLable = [[UILabel alloc]init];
        //self.titleLable.text = @"33333";
        self.titleLable.textColor = [UIColor colorWithRed:0.98 green:0.94 blue:0.87 alpha:1];
        self.titleLable.shadowColor = [UIColor grayColor];
        self.titleLable.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
        [self.contentView addSubview:self.titleLable];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.coverImg.frame = CGRectMake(0, 10, layoutAttributes.size.width, layoutAttributes.size.height);
    self.titleLable.frame = CGRectMake(10, layoutAttributes.size.height - 30, layoutAttributes.size.width - 20, 20);
    
}

- (void)setModel_destination:(CXDestinationModel *)model_destination
{
    _model_destination = model_destination;
    
    [self.coverImg sd_setImageWithURL:[NSURL URLWithString:self.model_destination.cover_s] placeholderImage:[UIImage sd_animatedGIFNamed:@"load"]];
    self.titleLable.text = self.model_destination.name;
}





@end
